package lee.study.fanshe;

class Student {
    private String name = "bit";
    public int age = 18;

    public Student() {
        System.out.println("student()");
    }

    private Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Student(String,name)");
    }

    private void eat() {
        System.out.println("eat");
    }

    public void sleep() {
        System.out.println("sleep");
    }

    private void function(String str) {
        System.out.println(str);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class TestDemo {
    public static void main(String[] args) {
    //拿到Class对象的三种方法：
        //1、
        Class c1 = null;
        try {
            c1 = Class.forName("lee.study.fanshe.Student");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        //2、
        Class c2 = Student.class;
        //3、
        Student s1 = new Student();
        Class c3 = s1.getClass();

        System.out.println(c1 == c2);
        System.out.println(c2 == c3);
        System.out.println(c1 == c3);
    }
}
